package org.droidexpress;

import org.droidexpress.data.read.LectureTournee;
import org.droidexpress.tools.SerializeClass;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class DroidExpressActivity extends Activity implements OnClickListener {
	Button boutonCharger = null;
	Button boutonQuitter = null;
    LectureTournee data = null;
    
    private static final int CODE_DE_MON_ACTIVITE = 1;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        data = new LectureTournee();
        data.lireTournee();
        
        boutonCharger = (Button)findViewById(R.id.mainCommencerTournee);
        boutonCharger.setOnClickListener(this); 
        
        boutonQuitter = (Button)findViewById(R.id.mainQuitter);        
        boutonQuitter.setOnClickListener(this);      
    }

	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId())
		{
		case R.id.mainCommencerTournee:
			Intent t = new Intent(DroidExpressActivity.this, VerifierTournee.class);
			
			Bundle mesDonnees = new Bundle();
			mesDonnees.putByteArray("tournee", SerializeClass.serializeObject(data.tournee));
			
			t.putExtras(mesDonnees);
			
			startActivityForResult(t, CODE_DE_MON_ACTIVITE);
			break;
		case R.id.mainQuitter:
			System.exit(0);
			break;
		}
	}
}